<div class="text-center" style="margin-top: 10%">
    <h1 class="text-muted"><i class="fa fa-frown-o"></i></h1>
    <h2 class="text-muted">您没有参与的项目</h2><br>
    <button class="btn btn-primary" data-toggle="modal" data-target="#mdl-add-proj">创建项目</button>
</div>

<!-- 新建项目对话框 -->
<div id="mdl-add-proj" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">新建项目</h5>
            </div>
            <div class="modal-body">
                <div id="err"></div>
                <form id="form-add-proj" action="/dashboard/projects/add" method="POST">
                    <div class="form-group">
                        <label for="add-proj-name">项目名</label>
                        <input id="add-proj-name" name="name" type="text" class="form-control" placeholder="项目名理应简短唯一" required autofocus>
                    </div>
                    <div class="form-group">
                        <label for="add-proj-role">您的职位分工</label>
                        <select class="form-control" id="add-proj-role" name="role">
                            {% for idx, title in ipairs(roles) do %}
                            <option value="{{idx}}">{{title}}</option>
                            {% end %}
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="add-proj-repo">项目仓库，非必填</label>
                        <input id="add-proj-repo" name="repo" type="text" class="form-control" placeholder="将在项目后显示连接">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="return add_proj();">确  定</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取  消</button>
            </div>
        </div>
    </div>
</div>

<script>
function add_proj() {
    $.ajax({
        url: '/dashboard/projects/add',
        type: 'POST',
        data: new FormData(document.getElementById('form-add-proj')),
        dataType: 'json',
        processData: false,
        contentType: false,
        cache: false,
        success: function(rsp) {
            if (rsp.ok) {
                $('#mdl-add-proj #err').empty();
                $('#mdl-add-proj').modal('hide');
                create_task();
            } else {
                showError('#mdl-add-proj #err', '创建项目失败', rsp.err_msg);
            }
        }
    });
}
</script>